package cn.iocoder.yudao.module.biz.controller.admin.pay.domain;

import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.excel.core.util.poi.annotation.Excel;
import cn.iocoder.yudao.module.biz.dal.dataobject.contract.ContractArchiveDO;
import com.baomidou.mybatisplus.annotation.*;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.apache.poi.ss.usermodel.HorizontalAlignment;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;

/**
 * 收款管理表
 * @TableName san_biz_payment_management
 */
@TableName(value ="san_biz_payment_management")
@Data
public class SanBizPaymentManagement implements Serializable{


    @Schema(description = "页码，从 1 开始", requiredMode = Schema.RequiredMode.REQUIRED,example = "1")
    @NotNull(message = "页码不能为空")
    @Min(value = 1, message = "页码最小值为 1")
    @TableField(exist = false)
    private Integer pageNo = 1;

    @Schema(description = "每页条数，最大值为 100", requiredMode = Schema.RequiredMode.REQUIRED, example = "10")
    @NotNull(message = "每页条数不能为空")
    @Min(value = 1, message = "每页条数最小值为 1")
    @Max(value = 100, message = "每页条数最大值为 100")
    @TableField(exist = false)
    private Integer pageSize = 10;

    /**
     * ID
     */
    @TableId
    private Long id;

    /**
     * 客户名称
     */
//    @Excel(name = "客户名称", dic = "sar_personType",dictType =  "sar_personType")
    private String name;



    /**
     * 客户ID
     */
    private String customerId;



    /**
     * 合同ID
     */
    private String contractId;

    /**
     * 合同编号
     */
    @Excel(name = "合同编号")
    private String contractCode;
    /**
     * 合同名称
     */
    @Excel(name = "合同名称")
    private String contractName;

    /**
     * 客户名称
     */
    @Excel(name = "客户名称")
    private String customerName;

    /**
     * 付款日期
     */
//    @Excel(name = "付款日期",align = HorizontalAlignment.LEFT, width = 30, dateFormat = "yyyy-MM-dd")
    private Date payDate;

    /**
     * 付款金额
     */
    @Excel(name = "付款金额")
    private BigDecimal payMoney;

    /**
     * 已匹配金额
     */
//    @Excel(name = "已匹配金额")
    private BigDecimal macthMoney;

    /**
     * 期数
     */
    @Excel(name = "期数")
    private String periods;

    /**
     * 收款内容
     */
    @Excel(name = "收款内容")
    private String content;

    /**
     * 需要匹配
     */
    @Excel(name = "需要匹配")
    private String needPay;

    /**
     * 匹配信息
     */
    @Excel(name = "匹配信息")
    private String macthInfo;

    /**
     * 经手人
     */
    @Excel(name = "经手人")
    private String recorderName;

    /**
     * 银行
     */
    @Excel(name = "银行")
    private String bankName;

    /**
     * 类型
     */
    @Excel(name = "类型", dic = "biz_pay_service_type",dictType =  "biz_pay_service_type")
    private String type;

    /**
     * 备注
     */
    @Excel(name = "备注")
    private String remarks;

    /**
     * 服务团队ID
     */
    private String serviceTeamId;

    /**
     * 服务团队
     */
    @Excel(name = "服务团队")
    private String serviceTeamName;

    /**
     * 录入日期
     */
    @Excel(name = "录入日期",align = HorizontalAlignment.LEFT, width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
    private Date recordDate;


    /**
     * 收款日期
     */
    @Excel(name = "应收款日期",align = HorizontalAlignment.LEFT, width = 30, dateFormat = "yyyy-MM-dd")
    private Date effectDate;

    /**
     * 部门
     */
    private Long deptId;

    /**
     * 层级顺序
     */
    private String layerOrder;

    /**
     * 共同执行人
     */
    private String coexecutor;


    /**
     * 版本号
     */
    private String versionNum;

    /**
     * 状态
     */
    @Excel(name = "状态")
    private String status;

    /**
     * 录入人ID
     */
    private Long recorderId;

    /**
     * 发票
     */
    @Excel(name = "发票")
    private String invoiceCodes;

    /**
     * 实际收款日期
     */
    @Excel(name = "实际收款日期",align = HorizontalAlignment.LEFT, width = 30, dateFormat = "yyyy-MM-dd")
    private Date payDateImp;

    /**
     * 订单号
     */
    private String orderNo;


    @TableField(exist = false)
    List<String> effectDateStr;


    /**
     * 应收金额
     */
    @Excel(name = "应收金额")
    private BigDecimal totalMoney;

    /**
     * 实收金额
     */
    private BigDecimal receivedMoney;

    /**
     * 本次匹配金额
     */
    @Excel(name = "本次匹配金额")
    private BigDecimal thisMacthMoney;

    /**
     * 对应服务期
     */
//    @Excel(name = "对应服务期-开始",align = HorizontalAlignment.LEFT, width = 30, dateFormat = "yyyy-MM-dd")
    private Date serviceDate;

    /**
     * 对应服务期
     */
//    @Excel(name = "对应服务期-结束",align = HorizontalAlignment.LEFT, width = 30, dateFormat = "yyyy-MM-dd")
    private Date serviceDateEnd;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    private String creator;

    private String updater;

    private LocalDateTime createTime;

    private LocalDateTime updateTime;

    @TableField(exist = false)
    private Integer offset; // = (new BigDecimal(this.pageNo).subtract(new BigDecimal(1))).multiply(new BigDecimal(this.pageSize)).intValue();

    public Integer getOffset() {
        return (new BigDecimal(this.pageNo).subtract(BigDecimal.ONE))
                .multiply(new BigDecimal(this.pageSize)).intValue();
    }
    /**
     *  是否删除
     */
    @TableLogic
    private Boolean deleted;

    @TableField(exist = false)
    @Schema(description = "合同信息")
    private ContractArchiveDO contractArchiveInfo;

    @TableField(exist = false)
    @Schema(description = "打款记录")
    private List<SanBizPaymentManagement> payment;

    @Schema(description = "分期记录ID")
    private Long contractReceiveRecordId;

    @Schema(description = "对应服务期")
    @Excel(name = "对应服务期")
    private String serviceTerm;


}
